%GETIMAGESYNC Get synchronised image pair via readBaumerMex.
%	Gets a pair of images via readBaumerMex as long as the images are not
%   in sync. The first pair of images which is in sync is returned.
%   If the synchronisation is lost entirely, an error is thrown.
%
% SYNTAX:
%   [img1, img2, counter, time] = getImageSync

function [img1, img2, counter, time]  = getImageSync
    async_counter = 0;
    [img1, img2, counter, time] = readBaumerMex('GetImage');
    while ( counter(1) ~= counter(2))
       async_counter = async_counter + 1;
       if async_counter > 100
           error('synchronisation lost!');
       end
       %fprintf('%d: images not in sync\n', loop_count);
       pause(0.005);
       [img1, img2, counter, time] = readBaumerMex('GetImage');
    end
end